package main

import (
	"encoding/json"
	"fmt"
	"net/http"
)

func main() {
	http.HandleFunc("/", Home)
	http.HandleFunc("/url/query", queryParam)
	err := http.ListenAndServe(":8080", nil)
	if err != nil {
		return
	}
}

func Home(w http.ResponseWriter, r *http.Request) {
	body := r.Body
	_, err := fmt.Fprintln(w, "接收到数据：%v", body)
	if err != nil {
		return
	}
}

func queryParam(w http.ResponseWriter, r *http.Request) {
	values := r.URL.Query()
	marshal, _ := json.Marshal(r.URL)
	_, _ = fmt.Fprintln(w, "接收到数据：%v", values)
	_, err := fmt.Fprintln(w, "接收到数据2：%v", string(marshal))
	if err != nil {
		return
	}
}
